<template>
  <div class="app-container">
    <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row>
      <el-table-column align="center" label='ID' min-width="80" prop="userId"></el-table-column>
      <el-table-column class-name="status-col" label="反馈人" min-width="110" align="center" prop="userName" show-overflow-tooltip></el-table-column>
      <el-table-column class-name="status-col" label="类别" min-width="110" align="center" prop="typeLabel"></el-table-column>
      <el-table-column class-name="status-col" label="内容" min-width="200" align="center" prop="description" show-overflow-tooltip></el-table-column>
      <el-table-column label="反馈时间" min-width="110" align="center">
        <template slot-scope="scope">{{scope.row.createTime|dateformat('YYYY-MM-DD HH:mm')}} </template>
      </el-table-column>
    </el-table>
    <div v-show="!listLoading" class="pagination-container">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.pageNo"
        :page-sizes="[10,20,30,50]" :page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>

import { getList } from '@/api/suggestion'

export default {
  data() {
    return {
      list: null,
      total: 0,
      listQuery:{
        pageNo:1,
        pageSize:10,
        beginTime:null,
        endTime:null,
        type:null,
        userId:null
      },
      listLoading: true
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      const { listQuery } = this
      getList(listQuery).then(response => {
        this.list = response.data['list']
        this.total = response.data['total']
        this.listLoading = false
      })
    },
    handleSizeChange(val) {
      this.listQuery.pageSize = val
      this.fetchData()
    },
    handleCurrentChange(val) {
      this.listQuery.pageNo = val
      this.fetchData()
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
  .pagination-container{
    margin-top:30px;
  }
</style>
